home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / skk / skk-comp.el.z / skk-comp.el
Encoding:
Text File  |  1998-05-21  |  6.7 KB  |  165 lines

  1. ;;; skk-comp.el --- $BJd40$N$?$a$N%W%m%0%i%`(B
  2. ;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
  3. ;; Masahiko Sato <masahiko@kuis.kyoto-u.ac.jp>
  4.  
  5. ;; Author: Masahiko Sato <masahiko@kuis.kyoto-u.ac.jp>
  6. ;; Maintainer: Mikio Nakajima <minakaji@osaka.email.ne.jp>
  7. ;; Version: $Id: skk-comp.el,v 1.2 1997/08/24 15:25:45 mrt Exp $
  8. ;; Keywords: japanese
  9. ;; Last Modified: $Date: 1997/08/24 15:25:45 $
  10.  
  11. ;; This program is free software; you can redistribute it and/or modify
  12. ;; it under the terms of the GNU General Public License as published by
  13. ;; the Free Software Foundation; either versions 2, or (at your option)
  14. ;; any later version.
  15.  
  16. ;; This program is distributed in the hope that it will be useful
  17. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. ;; GNU General Public License for more details.
  20.  
  21. ;; You should have received a copy of the GNU General Public License
  22. ;; along with SKK, see the file COPYING.  If not, write to the Free
  23. ;; Software Foundation Inc., 59 Temple Place - Suite 330, Boston,
  24. ;; MA 02111-1307, USA.
  25.  
  26. ;;; Commentary:
  27. ;; Following people contributed modifications to skk.el (Alphabetic order):
  28. ;;      Hitoshi SUZUKI <h-suzuki@ael.fujitsu.co.jp>
  29. ;;      Mikio Nakajima <minakaji@osaka.email.ne.jp>
  30.  
  31. ;;; Change log:
  32. ;; version 1.2.1 released 1997.2.2 (derived from the skk.el 8.6)
  33.  
  34. ;;; Code:
  35. (require 'skk-foreword)
  36. (require 'skk-vars)
  37. ;; Elib version 1.0 required.
  38. (require 'stack-m)
  39.  
  40. ;;; -- user variables
  41. (defvar skk-dabbrev-like-completion nil
  42.   "*Non-nil $B$G$"$l$P!"(Bdabbrev-expand $B$K;w$?8+=P$78l$NJd40$r9T$&!#(B
  43. $B$D$^$j!"(Bskk-insert-period $B$d(B skk-abbrev-period $B$GJd40$r9T$C$?>l9g$K!":G8e$KJd(B
  44. $B40$5$l$?8l$K$D$$$F99$KJd40$,9T$o$l$k!#(B
  45. $BNc$($P!"(B
  46.  
  47.   \"$B$5(B\" -> \"$B$5$H$&(B\" -> \"$B$5$H$&$;$s$;$$(B\"
  48.  
  49. nil $B$G$"$l$P!"@hF,$NJ8;z$r6&DL$K$9$kJ8;zNs$K$D$$$FJd40$,9T$J$o$l$k!#(B
  50. $BNc$($P!"(B
  51.  
  52.   \"$B$5(B\" -> \"$B$5$H$&(B\" -> \"$B$5$$$H$&(B\" -> \"$B$5$/$i(B\"" )
  53.  
  54. (defvar skk-comp-load-hook nil
  55.   "*skk-comp.el $B$r%m!<%I$7$?8e$K%3!<%k$5$l$k%U%C%/!#(B" )
  56.  
  57. ;;; -- internal variables
  58. ;; ---- buffer local variables
  59. ;; $B6uJ8;zNs$KBP$7$F(B skk-completion $B$r8F$V$3$H$b$"$j$&$k$N$G!"(B"" $B$r(B nil $B$G$OBe(B
  60. ;; $BMQ$G$-$J$$!#(B
  61. (skk-deflocalvar skk-completion-word ""
  62.   "$BJd40$9$Y$-8+=P$78l!#(B
  63. skk-dabbrev-like-completion $B$,(B non-nil $B$N>l9g$O!">o$K:G8e$KJd40$7$?8+=P$78l$,(B
  64. $BBeF~$5$l$k!#(B" )
  65. ;; $B<-=qEPO?;~%_%K%P%C%U%!$GJd40$7$?>l9g!"85$N%P%C%U%!$KLa$C$?$H$-$K(B 
  66. ;; skk-completion-word $B$NCM$,GK2u$5$l$F$$$J$$J}$,%Y%?!<!#(B
  67.  
  68. ;; skk-completion-stack $B$O%P%C%U%!%m!<%+%kCM$G$"$j!"$7$+$b(B stack-m.el $B$G$OGK2u(B
  69. ;; $BE*$K%j%9%H$rA`:n$9$k$N$G=i4|CM$O(B nil $B$K$7$F$*$/I,MW$,$"$k!#(B
  70. (skk-deflocalvar skk-completion-stack nil
  71.   "$BJd40$7$?8l$rJ]B8$7$F$*$/%9%?%C%/!#(B
  72. skk-previous-completion $B$G$O!"%9%?%C%/$+$i%]%C%W$7$F0JA0$KJd40$7$?8l$KLa$k!#(B" )
  73.  
  74. ;;;###skk-autoload
  75. (defun skk-start-henkan-with-completion (arg)
  76.   "$B"&%b!<%I$GFI$_$NJd40$r9T$J$C$?8e!"JQ49$9$k!#(B
  77. $B$=$l0J30$N%b!<%I$G$O%*%j%8%J%k$N%-!<%^%C%W$K3d$jIU$1$i$l$?%3%^%s%I$r%(%_%e%l!<(B
  78. $B%H$9$k!#(B"
  79.   (interactive "*P")
  80.   (if (and skk-henkan-on (not skk-henkan-active))
  81.       (progn
  82.         (skk-completion (not (eq last-command 'skk-completion)))
  83.         (skk-start-henkan arg) )
  84.     (skk-emulate-original-map arg) ))
  85.  
  86. ;;;###skk-autoload
  87. (defun skk-completion (first)
  88.   ;; skk-try-completion $B$N%5%V%k!<%A%s!#(B
  89.   (let ((inhibit-quit t)
  90.         skk-num-list
  91.         completion-word c-word )
  92.     (if first
  93.         (setq skk-completion-word
  94.               (skk-buffer-substring skk-henkan-start-point (point))
  95.               skk-completion-stack (stack-create) )
  96.       (if skk-dabbrev-like-completion
  97.           (setq skk-completion-word
  98.                 (skk-buffer-substring skk-henkan-start-point (point)) )))
  99.     (if (string= skk-completion-word "")
  100.         (skk-error "$B6uJ8;z$+$iJd40$9$k$3$H$O$G$-$^$;$s!*(B"
  101.                    "Cannot complete an empty string!" ))
  102.     ;; skk-completion-word $B$O%P%C%U%!%m!<%+%kCM$J$N$G!"<-=q%P%C%U%!$K0\$kA0$K(B
  103.     ;; $B0l;~JQ?t$K0\$7JQ$($F$*$/!#(B
  104.     (setq completion-word skk-completion-word)
  105.     (with-current-buffer (skk-get-jisyo-buffer skk-jisyo)
  106.       (if first (goto-char skk-okuri-nasi-min))
  107.       (save-match-data
  108.         ;; $B8zN($,NI$$$h$&$K(B kanji-flag, mc-flag, enable-multibyte-characters
  109.         ;; $B$r(B nil $B$K$7$F$*$/!#(B
  110.         ;; case-fold-search $B$O!"<-=q%P%C%U%!$G$O>o$K(B nil$B!#(B
  111.         (let (mc-flag)
  112.           ;;enable-multibyte-characters)
  113.           (while
  114.               (and (not c-word)
  115.                    (search-forward
  116.                     (concat "\n" 
  117.                             (if skk-use-numeric-conversion
  118.                                 (skk-compute-numeric-henkan-key completion-word)
  119.                               completion-word ))
  120.                     nil t ))
  121.             (if (eq (following-char) 32) ;SPC                      
  122.                 nil
  123.               (setq c-word (concat completion-word
  124.                                    (skk-buffer-substring
  125.                                     ;; $B8+=P$78l$K6uGr$O4^$^$l$J$$!#(B" /" $B$r%5!<(B
  126.                                     ;; $B%A$9$kI,MW$O$J$$!#(B
  127.                                     (point) (1- (search-forward " ")) ))))))))
  128.     ;; $B<-=q%P%C%U%!$N30!#(B
  129.     (if (not c-word)
  130.         (if skk-japanese-message-and-error
  131.             (error "\"%s\" $B$GJd40$9$Y$-8+=P$78l$O(B%s$B$"$j$^$;$s(B"
  132.                    skk-completion-word (if first "" "$BB>$K(B") )
  133.           (error "No %scompletions for \"%s\""
  134.                  (if first "" "more ") skk-completion-word ))
  135.       (stack-push skk-completion-stack c-word)
  136.       (delete-region skk-henkan-start-point (point))
  137.       (insert c-word) )))
  138.  
  139. ;;;###skk-autoload
  140. (defun skk-previous-completion ()
  141.   ;; skk-abbrev-comma, skk-insert-comma $B$N%5%V%k!<%A%s!#D>A0$KJd40$r9T$C$?8+(B
  142.   ;; $B=P$7$rA^F~$9$k!#(B
  143.   (let ((inhibit-quit t)
  144.         c-word )
  145.     (setq c-word (stack-pop skk-completion-stack))
  146.     (if (string= c-word
  147.                  (skk-buffer-substring skk-henkan-start-point (point)) )
  148.         ;;(null (memq last-command '(skk-abbrev-comma skk-insert-comma)))
  149.         ;; $B%]%C%W$7$?8l$,%P%C%U%!$N%]%$%s%HD>A0$K$"$kJ8;zNs$HF1$8$@$C$?$i(B 1 $B$D(B
  150.         ;; $B<N$F$k!#(B
  151.         (setq c-word (stack-pop skk-completion-stack)) )
  152.     (delete-region skk-henkan-start-point (point))
  153.     (if c-word
  154.         (insert c-word)
  155.       (insert skk-completion-word)
  156.       (skk-error "\"%s\"$B$GJd40$9$Y$-8+=P$78l$OB>$K$"$j$^$;$s(B"
  157.                  "No more previous completions for \"%s\""
  158.                  skk-completion-word ))
  159.     (setq this-command 'skk-completion) ))
  160.  
  161. (run-hooks 'skk-comp-load-hook)
  162.  
  163. (provide 'skk-comp)
  164. ;;; skk-comp.el ends here
  165.